<?php

//会员
defined('IN_PHPCMS') or exit('No permission resources.');
pc_base::load_app_class('foreground');

class like extends foreground {
    public $db;
    private $db_collect;
    private $uid;

    public function __construct() {
        parent::__construct();

        $this->uid = (int)param::get_cookie('_userid');
        $this->db_collect = pc_base::load_model('collect_model');
    }

    //关注 讲师
    public function teacher() {
        $like_arr = $this->db_collect->listinfo([
            'uid' => $this->uid,
            'a_catid' => 9,
        ], 'ymdhis desc');

        include template('member', 'like_teacher');
    }

    //关注 讲师 & 机构
    public function tt() {
        $teacher_arr = $this->db_collect->listinfo([
            'uid' => $this->uid,
            'a_catid' => 2,
        ], 'ymdhis desc');
        $teachers_arr='';
        $SuperStar = pc_base::load_model('SuperStar_model');
        foreach ($teacher_arr as &$v) {
            $teachers_arr[]=$SuperStar->get_one('id='.$v['a_id']);
        }
        
        $team_arr = $this->db_collect->listinfo([
            'uid' => $this->uid,
            'a_catid' => 10,
        ], 'ymdhis desc');

        include template('member', 'like_tt');
    }

    //关注课程
    public function classes() {
        $class1_arr = $this->db_collect->listinfo([
            'uid' => $this->uid,
            'a_catid' => 1,
        ], 'ymdhis desc');

        $class2_arr = $this->db_collect->listinfo([
            'uid' => $this->uid,
            'a_catid' => 2,
        ], 'ymdhis desc');

        include template('member', 'like_classes');
    }
    public function del_like() {
        $id=intval($_POST['id']);       
        $r=$this->db_collect->delete('uid='.$this->uid.' and a_catid=1 and a_id='.$id);
        
    }
}